<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" id="num1" placeholder="请输入一个数" />
    <select name="" id="calc">
      <option value="+">+</option>
      <option value="-">-</option>
      <option value="*">*</option>
      <option value="/">/</option>
    </select>
    <input type="text" id="num2" placeholder="请输入一个数" />
    <button id="btn">计算</button>
    <input type="text" id="reason" />
    <script>
      function mycalc(a, b, calc) {
        if (calc == "+") {
          return a + b;
        } else if (calc == "-") {
          return a - b;
        } else if (calc == "*") {
          return a * b;
        } else if (calc == "/") {
          return a / b;
        }
      }
      var num_1 = document.getElementById("num1");
      var calcEle = document.getElementById("calc");
      var num_2 = document.getElementById("num2");
      btn.onclick = function () {
        var a = parseInt(num_1.value);
        var b = parseInt(num_2.value);
        var c = calc.value;
        reason.value = mycalc(a, b, c);
      };
    </script>
  </body>
</html>
